(defun print-dl (dl stream depth)
  ( declare ( ignore depth))
  (format stream "~A" (dl->list dl)))

(defun dl->list (lst)
  (let ((dld nil))
     (if (dl-p lst)
	 (progn (if (stringp (dl-data lst))
		    (setf dld (format nil "\"~a\"" (dl-data lst)))
		    (setf dld (dl-data lst)))
		 (cons dld (dl->list (dl-next lst))))
	  lst)))

(defun dl-insert (x lst)
  ( let ((elt (make-dl :data x :next lst)))
    (if (dl-p (dl-data elt))
	  (setf (dl-prev (dl-data elt)) elt))
    (when  (dl-p lst)
      (if (dl-prev lst)
	   (setf (dl-next (dl-prev lst)) elt
		 (dl-prev elt) (dl-prev lst)))      
      (setf (dl-prev lst) elt))
    elt))

(defun dl-list ( &rest args)
  (reduce #'dl-insert args :from-end t :initial-value nil))

(defun dl-remove (lst)
  ( if (dl-prev lst)
       (setf (dl-next (dl-prev lst)) (dl-next lst)))
  ( if (dl-next lst)
       (setf (dl-prev (dl-next lst)) (dl-prev lst)))
  (dl-next lst))